﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Resume.Data.Model;

namespace Resume.Data.Mappers 
{
    public class ProjectMapper: EntityTypeConfiguration<Project>
    {
        public ProjectMapper()
        {
            this.ToTable("Projects");

            this.HasKey(p => p.Id);
            this.Property(p => p.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(p => p.Id).IsRequired();

            this.Property(p => p.Title).IsOptional();
            this.Property(p => p.Title).HasMaxLength(100);

            this.Property(p => p.Description).IsOptional();
            this.Property(p => p.Description).HasMaxLength(1000);

            this.HasRequired(p => p.Employer)
                .WithMany(p => p.Projects)
                .HasForeignKey(p => p.EmployerId);
        }
    }
}
